
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>项目信息</title>
    <!-- 	 引入jqmCalendar 文件资源  -->
    <link href="../resource/mp/jqmCalendar/jw-jqm-cal.css" rel="stylesheet">
    <script src="../resource/mp/jqmCalendar/jw-jqm-cal.js?_v=20140801"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <jsp:include page="../../../main/mp/inc.jsp"	/>
        <style>
            .toolAndroid {
                position:fixed !important;
                bottom: -11px !important;
                left:0px !important;
                width:100% !important;
                background-color:gainsboro;
            }
            .btn-txt[class='ui-btn-icon-left']{
                padding-left: 1.6em !important;
            }

            .toolIos{
               position:absolute !important;
               bottom: -11px !important;
               left:0px !important;
               width:99% !important;
               background-color:gainsboro;
            }
        </style>
</head>
<body>
	<!-- class="jqm-demos" -->
    <input type="hidden" id="hi_ids" value=""/>
	<div data-role="page" id="page-main" data-theme="a" style="padding-top: 44px !important; padding-bottom: 2px; position: relative; min-height: 594px;">
	    <div data-role="header" data-position="fixed" data-theme="a">
		    <h1 style="float:left;margin: 0 10px;">&nbsp;</h1>
            <div data-role="controlgroup" data-type="horizontal" class="ui-mini ui-btn-right">
                <a id="proinfo_singin" href="#" key="<s:property value="proInfo.id" />" class="ui-btn ui-shadow ui-btn-inline ui-icon-check ui-btn-a ui-corner-all ui-btn-icon-left">签到</a>
                <a id="proinfo_feedback" data-ajax="false" href="ajax-proback!input.action?proInfoId=<s:property value="proInfo.id" />"
                   class="ui-btn ui-shadow ui-btn-inline ui-icon-forward ui-btn-a ui-corner-all ui-btn-icon-left">反馈</a>
                <a id="proinfo_leave" data-ajax="false" href="ajax-proleave!input.action?proInfoId=<s:property value="proInfo.id" />"
                   class="ui-btn ui-shadow ui-btn-inline ui-icon-grid ui-btn-a ui-corner-all ui-btn-icon-left">请假</a>
            </div>
	    </div><!-- /header -->
	    <div class="ui-content jqm-content jqm-fullwidth" role="main">	
	    	<form method="post" id="form-common" action="linkman!save.action" data-ajax="false">
				<input type="hidden" id="keyId" name="keyId" value="<s:property value="proInfo.id" />">
				<div class="ui-field-contain">
					<fieldset data-role="controlgroup">
				        <legend>客户信息：</legend>
				    	<a href="ajax-client!read.action?keyId=<s:property value="proInfo.client.id" />" data-ajax="false"  class="ui-mini ui-btn ui-btn-icon-right ui-icon-carat-r"><s:property value="proInfo.client.name" /></a>
				    </fieldset>
				</div>
				<div class="ui-field-contain">
				    <label>项目名称：</label>
				    <span><s:property value="proInfo.name" /></span>
				</div>
				<div class="ui-field-contain">
				    <label>项目类别：</label>
				    <span><s:property value="proInfo.category.name" /></span>
				</div>
				
				<div class="ui-field-contain">
				    <label>客户名称：</label>
				    <span><s:property value="proInfo.client.name" /></span>
				</div>
				<div class="ui-field-contain">
				    <label>联系人：</label>
				     <span><s:property value="proInfo.linkman.name" /></span>
				</div>
				<div class="ui-field-contain">
				    <label>所在区域：</label>
				    <span ><s:property value="proInfo.province" /><s:property value="proInfo.city" /><s:property value="proInfo.county" /></span>
				</div>
				<div class="ui-field-contain">
				    <label >项目地址：</label>
				    <span ><s:property value="proInfo.address" /></span>
				</div>
				<div class="ui-field-contain">
				    <label>项目总监：</label>
				    <span><s:property value="proInfo.chief.name" /></span>
				</div>
				
				<div class="ui-field-contain">
				    <label>项目组成员：</label>
				    <span >
                        <s:iterator value="proInfo.group" id="list">
                            <s:property value="#list.name"></s:property>
                        </s:iterator>
				    </span>
				</div>
				
				<div class="ui-field-contain">
				    <label>启动时间：</label>
				    <span >
                        <s:date name="proInfo.start" format="yyyy-MM-dd"></s:date>
                    </span>
				</div>
				<div class="ui-field-contain">
				    <label>完成时间：</label>

				    <span >
                        <s:date name="proInfo.end" format="yyyy-MM-dd"></s:date>
                    </span>
				</div>
                <div class="ui-field-contain">
                    <label>
                        新建人:
                    </label>
                    <span><s:property value="proInfo.creater.name" /></span>
                </div>
                <div class="ui-field-contain">
                    <label>
                    </label>
                    <span></span>
                </div>
			</form>
	    	
		</div><!-- /content -->
        <div data-role="footer" data-position="fixed" data-theme="a">
            <div data-role="navbar" data-iconpos="top" >
                <div data-role="footer" data-position="fixed" data-theme="a">
                    <div data-role="navbar" data-iconpos="top" >
                        <ul>
                            <li><a id="page-main-action" data-ajax="false" data-icon="calendar">基本信息</a></li>
                            <li><a id="page-comment-action"  data-icon="comment">批注信息</a></li>
                            <li><a id="page-prosignin-action" data-ajax="false" data-icon="shop" prokey="<s:property value="proInfo.id" />">考勤日历</a></li>
                            <li><a id="page-proback-action" data-icon="bars">反馈列表</a></li>
                        </ul>
                    </div><!-- /navbar -->
                </div><!-- /footer -->
            </div><!-- /navbar -->
        </div><!-- /footer -->
	</div><!-- /page -->

    <!-- 页面批注-->
    <div data-role="page" id="page-comment" data-theme="a" targetId="<s:property value="proInfo.id" />" targetObject="com.joint.core.entity.ProInfo" data="{}" createrId="<s:property value="proInfo.creater.id" />">
        <div data-role="header">
            <a href="#" key="page-main-action" data-ajax="false" id="" class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
            <h1>【<s:property value="proInfo.name" />】批注信息</h1>
            <%--<a href="#" key="comment-popup2" data-rel="popup" parentId='' createrName='<s:property value="proInfo.creater.name"/> 请填写批注信息' createrId='<s:property value="proInfo.creater.id"/>' data-transition="pop" class="ui-btn ui-btn-right ui-icon-comment ui-corner-all ui-btn-icon-left ui-btn-icon-notext" data-position-to="window" data-icon="comment" data-prefetch="true">发表批注</a>--%>
        </div><!-- /header -->
        <div role="main" class="ui-content" id="comment-listview-content"
             mp-url="ajax-comment!listDocument.action?keyId=<s:property value="proInfo.id" />">
            <div>
                <ul data-role="listview" data-theme="a" data-dividertheme="b"
                    mp-page="1" mp-keyword="" data-split-icon="forward" data-split-theme="a" data-inset="false">
                    <li><a data-ajax="false"  href="javascript:void(0)">
                        没有批注信息.
                    </a>
                    </li>
                </ul>
            </div>
            <div style="height: 40px;">

            </div>
            <div id="ToolBar">
                <table style="width:100%">
                    <tr>
                        <td>
                            <img id="btn_choose" src="../resource/com/img/add-18.png" style="float: right;"/>
                            <%--<a href="#" data-role="button" id="btn_choose" data-icon="plus" style="display: block;height: 12px;margin-top: 7px;margin-left: -2px;margin-right:-4px;padding-left:1.6em;border-radius:0px;"></a>--%>
                        </td>
                        <td>
                            <input type="text" placeholder="请输入内容"  id="chart_user"  name="chart_user" />
                        </td>
                        <td>
                            <img id="chart_btn" src="../resource/com/img/yes-19.png"  style="float: left"/>
                            <%--<a href="#" data-role="button" id="chart_btn" data-icon="check" style="display: block;margin-top: 7px;height: 12px;margin-left: -4px;margin-right: -4px;padding-left:1.6em;border-radius:0px;"></a>--%>
                        </td>
                    </tr>
                </table>
            </div>

            <%--<div id="ToolBar">--%>
                <%--<div class="ui-field-contain">--%>
                    <%--<select  name="proinfo_com" id="proinfo_com" multiple>--%>
                        <%--<s:iterator value="userListMap.keySet()" id="list">--%>
                            <%--<optgroup label="<s:property value="#list"/>">--%>
                                <%--<s:iterator value="userListMap.get(#list)" id="user">--%>
                                    <%--<option value="<s:property value="#user.id"/>"> <s:property value="#user.name" /></option>--%>
                                <%--</s:iterator>--%>
                            <%--</optgroup>--%>
                        <%--</s:iterator>--%>
                    <%--</select>--%>
                <%--</div>--%>
                <%--<div>--%>
                    <%--<input   type="text" id="comtext" name="comtext"/>--%>
                    <%--<button style="color: black;" type="button" >提交</button>--%>
                <%--</div>--%>
            <%--</div>--%>

            <div data-role="popup" id="comment-popup2" data-theme="a" class="ui-corner-all" data-history="false" data-corners="false">
                <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-left">Close</a>
                <form>
                    <div style="padding:0 8px;">
                        <textarea cols="40" rows="8" name="comment" placeholder="请填写您的批注信息"></textarea>
                        <button type="button" class="ui-btn ui-corner-all ui-shadow ui-btn-b ui-btn-icon-left ui-icon-check">提交批注</button>
             </div>
                </form>
            </div>
        </div><!-- /content -->

    </div><!-- /page comment -->

    <!-- 考勤日历 -->
    <div data-role="page" id="page-prosignin" data-theme="a" >
        <div data-role="header">
            <a href="#" key="page-main-action" data-ajax="false" class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
            <h1>【<s:property value="proInfo.name" />】考勤日历</h1>
        </div>
        <div data-role="content">
            <div id="calendar"></div>
        </div>
    </div>

    <!-- 页面反馈-->
    <div data-role="page" id="page-proback" data-theme="a" >
        <div data-role="header"  >
            <a href="#" key="page-main-action" data-ajax="false"  class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
            <h1>【<s:property value="proInfo.name" />】反馈信息</h1>
        </div><!-- /header -->
        <div role="main" class="ui-content" id="proback-listview-content"
             mp-url="ajax-proback!list.action?proInfoId=<s:property value="proInfo.id" />">
            <ul data-role="listview" data-theme="a" data-dividertheme="b"
                mp-page="1" mp-keyword="" data-split-icon="forward" data-split-theme="a" data-inset="false">
                <li><a data-ajax="false"  href="javascript:void(0)">
                    没有反馈信息.
                </a>
                </li>
            </ul>
            <hr/>
            <div>
                <a href="#" key="prePage" class="ui-btn ui-btn-icon-notext ui-corner-all  ui-mini ui-btn-inline ui-icon-carat-l "> 上一页</a>
                <a href="#" key="nextPage" class="ui-btn ui-btn-icon-notext ui-corner-all  ui-mini ui-btn-inline ui-icon-carat-r ">下一页 </a>
                    <span class="ui-btn-inline">
                        页数  <span key="pageNumber1"></span>/<span key="pageCount1"></span> 共<span key="totalCount1"></span>条
                    </span>
            </div>

        </div><!-- /content -->
    </div>

    <div data-role="page" id="page-user" data-theme="a">
        <div data-role="header"  data-position="fixed">
            <a href="#page-comment" key="page-comment-action" data-ajax="false"  class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
            <h1>请选择要回复的人</h1>
            <a id="comuser_btn" mp-panel-id="proinfo-listview-panel" href="#" class="ui-btn ui-shadow ui-mini ui-btn-right">确认</a>
            <%--<div id="search"  class="ui-field-contain" style="margin:0;padding:0;">--%>
                <%--<input type="search" name="search-mini" placeholder="按姓名搜索" id="search-mini" value="" />--%>
                <%--<a href="javascript:void(0)" id="search-button"  data-ajax="false" class="ui-btn">查询</a>--%>
            <%--</div>--%>
        </div>
        <div role="main" class="ui-content" id="comment-user-content"
             mp-url="ajax-comment!usersPage.action">
            <div id="scroller">
                <!-- 下拉按钮 new -->
                <%--<div id="pullDown">--%>
                    <%--<span class="pullDownIcon"></span> <span class="pullDownLabel">下拉松开刷新...</span>--%>
                <%--</div>--%>
                <ul data-role="listview" data-theme="a" data-dividertheme="b"
                    mp-page="1" mp-keyword="" data-split-icon="forward" data-split-theme="a" data-inset="false">
                    <li>
                    </li>
                </ul>
                <!-- 上拉按钮 new -->
                <%--<div id="pullUp">--%>
                    <%--<span class="pullUpIcon"></span><span class="pullUpLabel">上拉显示更多...</span>--%>
                <%--</div>--%>
            </div>

        </div>
    </div>


</body>
</html>
<script>

    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '<s:property value="jsapiSignature.appId" />', // 必填，公众号的唯一标识
        timestamp: '<s:property value="jsapiSignature.timestamp" />', // 必填，生成签名的时间戳
        nonceStr: '<s:property value="jsapiSignature.noncestr" />', // 必填，生成签名的随机串
        signature: '<s:property value="jsapiSignature.signature" />',// 必填，签名，见附录1
        jsApiList: ['checkJsApi', 'getLocation'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
</script>
<script>
    Date.prototype.Format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }

    var firstDate;
    function initCalendar(){
        //var prokey = $("a#page-prosignin-action").attr("prokey");
        var myDate = new Date();
        if(myDate.getMonth() < 9){
            var month = "0"+(myDate.getMonth()+1);
        }else{
            var month = myDate.getMonth()+1;
        }
        firstDate = myDate.getFullYear()+"-"+month+"-01";
        $.ajax({
            type 	: "POST",
            url 	: 'ajax-calendar!listCalendarView.action?proInfoId='+$("a#page-prosignin-action").attr("prokey"),
            data    : {"month":firstDate},
            dataType : 'json',
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            cache : false,
            success:function(data){
                var cals = [];
                $(data.data.dataRows).each(function(i,v){
                    var dateObj =new Date(v.begin['time']);
                    var endObj = new Date(v.end['time']);
                    var cal={
                        "summary" :v.summary,
                        "begin" :dateObj,
                        "end" :endObj,
                        "url":v.url
                    }
                    cals.push(cal);
                });
                jqmCalendar = $("#calendar").jqmCalendar({
                    events : cals,
                    months : ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                    days : ["日", "一", "二", "三", "四", "五", "六"],
                    startOfWeek : 0,
                    source : 'ajax-calendar!listCalendarView.action?proInfoId='+$("a#page-prosignin-action").attr("prokey"),
                    allDayTimeString: ''
                });
            }
        })
    }

    //详情页面
    $(function(){
        //签到操作
        $("#proinfo_singin").off("click").on("click",function(e){
            var id=$(this).attr("key");
            $.mobile.loading( "show", {
                text: "正在获取地理位置，请稍后...",
                textVisible: true,
                theme: "b",
                textonly: false,
                html: ""
            });
            getCheckInfo(id);
//            ajax_action(url,data,null,function(pdata){
//                alert(pdata.result.errorMessage);
//                $("#popupMenu").popup("close");
//
//                if(pdata.result.errorCode == 1){
//                    $("a#page-prosignin-action").trigger("click");
//                }
//
//            });
        });
        function getCheckInfo(id){
            wx.ready(function(){
                wx.getLocation({
                    success: function (res) {
                        hide();
                        //var data = {keyId:id,latitude:res.latitude,longitude:res.longitude};
                        submitCheckInfo(id,res.latitude,res.longitude)
                    },
                    fail : function(){
                        hide();
                        alert("获取位置失败，请确认是否开启GPS定位功能!");
                    }
                });
            });
        }
        function submitCheckInfo(id,latitude,longitude){
            $.mobile.loading( "show", {
                text: "正在保存，请稍后...",
                textVisible: true,
                theme: "b",
                textonly: false,
                html: ""
            });
            $.ajax({
                type: "POST",
                url: "ajax-proinfo!assign.action",
                cache:false,dataType:"json",
                data:{keyId:id,latitude:latitude,longitude:longitude},
                async:true,
                success: function(data){
                    hide();
                    if(data.result.errorCode == 404 || data.result.errorCode == "404"){
                        alert(data.result.errorMessage);
                    }else{
                        alert(data.result.errorMessage);
                        $("a#page-prosignin-action").trigger("click");
                    }
                },
                error: function(){
                    hide();
                }
            });
        }

        //返回项目批注页面
        $("#page-comment-action").off("click").on("click",function(){
            $(':mobile-pagecontainer').pagecontainer('change', '#page-comment',{changeHash: false,reverse: true,transition:'slidedown'});
            loadListview($("#comment-listview-content"),{},function(rdata){
                $("a[key=comment-popup2]").unbind('click').bind("click",function(e){
                    $( "#comment-popup2" ).data("parentId",$(this).attr("parentId")).data("createrId",$(this).attr("createrId"));
                   // $( "#comment-popup2 textarea" ).attr("placeholder","@"+$(this).attr("createrName"));
                    $( "#comment-popup2" ).popup( "open", {transition:'pop',positionTo:'window'} );
                    $("#proinfo_com-button").hide();
                })
            })
        });

//        $("#chart_user").bind("input propertychange",function(){
//            if( $(this).val().indexOf("@")!=-1){
//                $(':mobile-pagecontainer').pagecontainer('change', '#page-user',{changeHash: false,reverse: true,transition:'slideup'});
//                loadListview($("#comment-user-content"),{},function(rdata){
//
//                })
//                //$.mobile.loadPage( "../main/mp/action-comment.jsp");
//            }
//        });

        $("#btn_choose").click(function(){
            $(':mobile-pagecontainer').pagecontainer('change', '#page-user',{changeHash: false,reverse: true,transition:'slideup'});
            loadListview($("#comment-user-content"),{},function(rdata){

            })

        });
        //发表批注对话框的提交按钮
        $("#chart_btn").bind("click",function(e){
            //alert(1);
            //隐藏popup
            var toUsersId = $( "#hi_ids").val();
            //var createrId = $( "#comment-popup2" ).data("createrId");
            var text = $( "#chart_user" ).val();

            var targetId = $("#page-comment").attr("targetId");
            var targetObject = $("#page-comment").attr("targetObject");
            //alert(parentId + " " + createrId + " " + text + " " + targetId + " " + targetObject);
            sendComment(null,toUsersId,text,targetId,targetObject,function(){
            });
        })
    })

</script>

<script>
//    $("#search-button").off("click").on("click",function(){
//        $("#comment-user-content").attr("mp-url", "ajax-comment!usersPage.action?searchString="+$("#search-mini").val());
//        listSearch();
//    });

    $(function(){
        //返回项目基本信息页
        $("a#page-main-action , a[key='page-main-action']").click(function(){
            $(':mobile-pagecontainer').pagecontainer('change', '#page-main',{changeHash: false,reverse: true,transition:'slideup'});
        })

        $("a#page-comment-action , a[key='page-comment-action']").click(function(){
            $(':mobile-pagecontainer').pagecontainer('change', '#page-comment',{changeHash: false,reverse: true,transition:'slideup'});
        })

        $("a#page-proback-action").click(function(){
            $(':mobile-pagecontainer').pagecontainer('change', '#page-proback',{changeHash: false,reverse: true,transition:'slideup'});
            loadListview($("#proback-listview-content"),{},function(rdata){

            })
        });


        $("a#page-prosignin-action").click(function(){
            $(':mobile-pagecontainer').pagecontainer('change', '#page-prosignin',{changeHash: false,reverse: true,transition:'slideup'});
            initCalendar();
        })

        $("#calendar").bind('change', function(event, date) {
            //用户某一天的切换
            //console.debug(date);
        });

        $("[data-role='navbar']").navbar();
        $("[data-role='header'], [data-role='footer']").toolbar();
    });
</script>

<script>
$(function(){
    $("#comuser_btn").click(function(){
        var ids='';
        var names='';
        $("input[name='check_user']:checked").each(function(i,v){
            ids+=$(this).attr("id")+",";
            //names+="@"+$(this).attr("key")+" ";
        });
        $("#hi_ids").val(ids);
        //$("#chart_user").val(names);
        $(':mobile-pagecontainer').pagecontainer('change', '#page-comment',{changeHash: false,reverse: true,transition:'slideup'});
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        if(isiOS){
            document.body.scrollTop = 90000;

        }
    });

});

</script>
<script type="text/javascript">
$(function(){
      var u = navigator.userAgent, app = navigator.appVersion;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        $("#ToolBar").addClass("toolAndroid");
        if(isiOS){
            $('#chart_user').focus(function(){
                  var body = $('body').height();
                  var comment_listview = $("#comment-listview-content").height();
                  if(body>comment_listview){
                    document.body.scrollTop = body;
                  }else{
                    $("#ToolBar").removeClass().addClass("toolIos");
                    document.body.scrollTop = comment_listview;
                  }

            });
            $('#chart_user').blur(function(){
                 $("#ToolBar").removeClass().addClass("toolAndroid");
            });
        }
});



</script>